package org.example.myleet.p762;

import java.util.HashSet;

public class Solution {

    private static final HashSet<Integer> PRIME_NUMBERS = new HashSet<>();

    static {
        PRIME_NUMBERS.add(2);
        PRIME_NUMBERS.add(3);
        PRIME_NUMBERS.add(5);
        PRIME_NUMBERS.add(7);
        PRIME_NUMBERS.add(11);
        PRIME_NUMBERS.add(13);
        PRIME_NUMBERS.add(17);
        PRIME_NUMBERS.add(19);
        PRIME_NUMBERS.add(23);
        PRIME_NUMBERS.add(29);
        PRIME_NUMBERS.add(31);
    }

    public int countPrimeSetBits(int left, int right) {
        int count = 0;
        for (int i = left; i <= right; ++i) {
            if (PRIME_NUMBERS.contains(Integer.bitCount(i))) {
                ++count;
            }
        }
        return count;
    }
}
